import moment from 'moment'

export function getformDatas(data: any) {
	const {
		socialCreditCode,
		abbreviation,
		supplierName,
		supplierCode,
		supplierCreator,
		ratingCycle,
	} = data

	const {
		examineOrgId,
		reason,
		enterpriseNature,
		address,
		payCondition,
		invoicingRate,
		telephone,
		contacts,
		mobilePhone,
		email,
		registeredCapital,
		establishDate,
		postalCode,
		companyIntroduction,
		accountBankName,
		accountName,
		bankAccount,
		bankName,
		support,
		provinceId,
		cityId,
		settlementMethod,
		earnestMoney,
	} = data?.supplierBase || {}

	const admittanceValue = {
		supplierType: data.supplierType.split(','),
		socialCreditCode,
		supplierName,
		abbreviation,
		supplierCode,
		supplierCreator,
		examineOrgId,
		orgId: data?.orgId?.split(','),
		ratingCycle,
		reason,
	}

	const basicsValue = {
		enterpriseNature,
		address,
		payCondition,
		invoicingRate,
		telephone,
		contacts,
		mobilePhone,
		email,
		registeredCapital,
		establishDate: moment(establishDate),
		postalCode,
		companyIntroduction,
		city: [provinceId, cityId],
		settlementMethod,
		earnestMoney,
	}

	const bankValue = {
		support,
		bankName,
		accountName,
		bankAccount,
		accountBankName,
	}

	return {
		admittanceValue,
		basicsValue,
		bankValue,
	}
}
